package com.syni.mdd.sjb.common.datatreaure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.DxshAppServiceSon;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.mapper.DxshAppServiceSonMapper;
import com.syni.mdd.sjb.common.component.utils.common.utils.BeanUtils;
import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.sjb.common.datatreaure.constants.Constants;
import com.syni.mdd.sjb.common.datatreaure.constants.ResultMsg;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rp.service.SonTagRpVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.services.GetSonsByFatherRqVo;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppServiceSonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 电享生活APP 服务子类表 服务实现类
 * </p>
 *
 * @author lcc
 * @since 2020-04-26
 */
@Service
public class DxshAppServiceSonServiceImpl extends ServiceImpl<DxshAppServiceSonMapper, DxshAppServiceSon> implements DxshAppServiceSonService {

    @Autowired
    DxshAppServiceSonMapper dxshAppServiceSonMapper;

    @Override
    public Map<String, Object> getSonsByFather(GetSonsByFatherRqVo getSonsByFatherRqVo) {
        List<DxshAppServiceSon> dxshAppServiceSonList = this.list(new QueryWrapper<DxshAppServiceSon>().
                eq(DxshAppServiceSon.FATHER_ID,getSonsByFatherRqVo.getFatherId())
                .eq(DxshAppServiceSon.IS_DELETE, Constants.COMMON_FLAG_FALSE_INT));
        List<SonTagRpVo> sonTagRpVos = BeanUtils.copyList(dxshAppServiceSonList,SonTagRpVo.class);
        return ResultMapHelper.success(sonTagRpVos, ResultMsg.MSG_GET_SUCCESS);
    }

    @Override
    public Map<String, Object> getServiceType() {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(DxshAppServiceSon.IS_DELETE, Constants.COMMON_FLAG_FALSE_INT);
        List<DxshAppServiceSon> dxshAppServiceSonList = dxshAppServiceSonMapper.selectList(queryWrapper);
        List<SonTagRpVo> sonTagRpVos = BeanUtils.copyList(dxshAppServiceSonList,SonTagRpVo.class);
        return ResultMapHelper.success(sonTagRpVos, ResultMsg.MSG_GET_SUCCESS);
    }

    @Override
    public Map<Integer, DxshAppServiceSon> getNameByIds(Set<Integer> ids) {
        Map<Integer, DxshAppServiceSon> dxshAppServiceSonMap = new HashMap<>();
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.in(DxshAppServiceSon.ID, ids);
        List<DxshAppServiceSon> dxshAppServiceSons = dxshAppServiceSonMapper.selectList(queryWrapper);
        for(DxshAppServiceSon d :dxshAppServiceSons){
            dxshAppServiceSonMap.put(d.getId(),d);
        }
        return dxshAppServiceSonMap;
    }


}
